//index.js
//获取应用实例
var app = getApp()
var admin_id = app.globalData.admin_id;
var cat_id = 0;
var share = app.globalData.share;
Page({
	data: {
		name:'商品'
	},
	onLoad: function (o) {
		var that = this;
		console.log("管理员ID ====" + admin_id);
		
		wx.request({
			url: app.globalData.host + 'index.php/api/goods/goodsInfo?admin_id=' + admin_id,
			success: function (e) {
				
				cat_id = o.id;
				that.setData({
					news: e.data.result.filter(that.filterHeaderCatid),
					name: o.name
				})

			}
		})

		that.setData({
			intB: app.globalData.intB,
			sw_int: app.globalData.sw_int
		})
	},
	filterHeaderCatid: function (e) {
		return (e.cat_id == cat_id)
	},
	goodsClick: function (e) {
		console.log(e)
		wx.navigateTo({
			url: '../../pages/goods/goods?id=' + e.currentTarget.dataset.id + '&type=' + e.currentTarget.dataset.type,
		})
	},
	onShareAppMessage: function () {
		return {
			title: share,
			path: 'pages/index/index'
		}
	}
})
